package com.safe.first.application.dto.cmd;

import com.safe.first.domain.user.DefaultUser;
import com.safe.first.domain.user.factory.DefaultUserFactory;
import lombok.Data;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @author Mickey
 * @since 2022/6/17
 **/
@Data
public class CreateUserCmd implements DefaultUserFactory.UserFactoryParam {

    @NotNull
    @Pattern(regexp = "^1(3\\d|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$", message = "格式不正确")
    private String mobile;
    private String username;
    private String password;

    @Override
    public DefaultUser converter() {
        DefaultUser defaultUser = new DefaultUser();
        defaultUser.setMobile(mobile);
        defaultUser.setUsername(username);
        defaultUser.setPassword(password);
        return defaultUser;
    }
}
